export default{
    namespaced:true,
    state: {
        sum: 0, //当前的和
        school: "衡阳技师学院",
        subject: "Vue",
    },
    mutations: {
        JIA(state, value) {
            console.log('mutations中的jia被调用了')
            state.sum += value
        },
        JIANG(state, value) {
            console.log('mutations中的jiang被调用了')
            state.sum -= value
        }
    },
    getters: {
        bigSum(state) {
            return state.sum * 10
        }
    },
    actions: {
        jiaOdd(context, value) {
            console.log('actions中的jiaOdd被调用了')
            if (context.state.sum % 2) {
                context.commit('JIA', value);
            }
        },
        addWait(context, value) {
            console.log('actions中的addWait被调用了')
            setTimeout(() => {
                context.commit('JIA', value);
            }, 500)
        },
    }
}